package com.tengju.user.domain.model.sms;


import com.tengju.user.domain.model.user.StarLevelEnum;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Random;

@Component
public class SmsTempFactory {


    static Integer smsVerifyCodeTemp;

    static Integer smsSignInviteTemp;

    static Integer smsSignSuccessTemp;

    static Integer smsSignAuditSuccessTemp;

    static Integer smsSignAuditFailTemp;

    static Integer smsChargeApplyVerifyFailTemp; //审核拒绝通知

    static Integer smsChargeEarlyVerifySuccessTemp; //初审通过

    static Integer smsChargeEarlyVerifyFailTemp; //初审未通过

    static Integer smsChargeRecheckRejectTemp; //复审未通过

    static Integer smsChargeUnbindAccountTemp; //已解绑服务费收款账户

    static Integer smsChargeModeChangeTemp; //合作方式变更

    static Integer smsChargeDistributeSuccessTemp; //服务费发放成功

    static Integer smsChargeDistributeFailTemp; //服务费发放失败

    static Integer smsChargeAuthFailTemp; //认证审核失败

    static Integer smsChargeBatchPaymentCodeTemp; //批量验证码

    static Integer smsStarUpcomingNoticeTemp; //即将晋升提醒

    @Value("${user.smsTempId.star.upcoming.notice}")
    public void setSmsStarUpcomingNoticeTemp(Integer smsStarUpcomingNoticeTemp) {
        SmsTempFactory.smsStarUpcomingNoticeTemp = smsStarUpcomingNoticeTemp;
    }

    @Value("${user.smsTempId.verifycode}")
    public void setSmsVerifyCodeTemp(Integer smsVerifyCodeTemp) {
        SmsTempFactory.smsVerifyCodeTemp = smsVerifyCodeTemp;
    }

    @Value("${user.smsTempId.sign.invite}")
    public void setSmsSignInviteTemp(Integer smsSignInviteTemp) {
        SmsTempFactory.smsSignInviteTemp = smsSignInviteTemp;
    }

    @Value("${user.smsTempId.sign.success}")
    public void setSmsSignSuccessTemp(Integer smsSignSuccessTemp) {
        SmsTempFactory.smsSignSuccessTemp = smsSignSuccessTemp;
    }

    @Value("${user.smsTempId.sign.audit.success}")
    public void setSmsSignAuditSuccessTemp(Integer smsSignAuditSuccessTemp) {
        SmsTempFactory.smsSignAuditSuccessTemp = smsSignAuditSuccessTemp;
    }

    @Value("${user.smsTempId.sign.audit.fail}")
    public void setSmsSignAuditFailTemp(Integer smsSignAuditFailTemp) {
        SmsTempFactory.smsSignAuditFailTemp = smsSignAuditFailTemp;
    }


    @Value("${user.smsTempId.charge.apply.verifyreject}")
    public void setSmsChargeApplyVerifyFailTemp(Integer smsChargeApplyVerifyFailTemp) {
        SmsTempFactory.smsChargeApplyVerifyFailTemp = smsChargeApplyVerifyFailTemp;
    }

    @Value("${user.smsTempId.charge.apply.pass}")
    public void setSmsChargeEarlyVerifySuccessTemp(Integer smsChargeEarlyVerifySuccessTemp) {
        SmsTempFactory.smsChargeEarlyVerifySuccessTemp = smsChargeEarlyVerifySuccessTemp;
    }

    @Value("${user.smsTempId.charge.apply.reject}")
    public void setSmsChargeEarlyVerifyFailTemp(Integer smsChargeEarlyVerifyFailTemp) {
        SmsTempFactory.smsChargeEarlyVerifyFailTemp = smsChargeEarlyVerifyFailTemp;
    }

    @Value("${user.smsTempId.charge.apply.recheckreject}")
    public void setSmsChargeRecheckRejectTemp(Integer smsChargeRecheckRejectTemp) {
        SmsTempFactory.smsChargeRecheckRejectTemp = smsChargeRecheckRejectTemp;
    }

    @Value("${user.smsTempId.charge.account.unbind}")
    public void setSmsChargeUnbindAccountTemp(Integer smsChargeUnbindAccountTemp) {
        SmsTempFactory.smsChargeUnbindAccountTemp = smsChargeUnbindAccountTemp;
    }

    @Value("${user.smsTempId.charge.account.changemode}")
    public void setSmsChargeModeChangeTemp(Integer smsChargeModeChangeTemp) {
        SmsTempFactory.smsChargeModeChangeTemp = smsChargeModeChangeTemp;
    }

    @Value("${user.smsTempId.charge.account.authfail}")
    public void setSmsChargeAuthFailTemp(Integer smsChargeAuthFailTemp) {
        SmsTempFactory.smsChargeAuthFailTemp = smsChargeAuthFailTemp;
    }

    @Value("${user.smsTempId.charge.distribute.success}")
    public void setSmsChargeDistributeSuccessTemp(Integer smsChargeDistributeSuccessTemp) {
        SmsTempFactory.smsChargeDistributeSuccessTemp = smsChargeDistributeSuccessTemp;
    }

    @Value("${user.smsTempId.charge.distribute.fail}")
    public void setSmsChargeDistributeFailTemp(Integer smsChargeDistributeFailTemp) {
        SmsTempFactory.smsChargeDistributeFailTemp = smsChargeDistributeFailTemp;
    }

    @Value("${user.smsTempId.charge.batchpayment}")
    public void setSmsChargeBatchPaymentCodeTemp(Integer smsChargeBatchPaymentCodeTemp) {
        SmsTempFactory.smsChargeBatchPaymentCodeTemp = smsChargeBatchPaymentCodeTemp;
    }


    public static SmsVerifyCode fourSmsCode(String mobile, String areaCode) {
        String code = String.format("%04d", new Random().nextInt(9999));
        return new SmsVerifyCode(
                smsVerifyCodeTemp,
                mobile,
                code,
                areaCode
        );
    }

    public static SmsSignInvite smsSignInvite(String mobile, StarLevelEnum starLevel) {
        return new SmsSignInvite(
                smsSignInviteTemp,
                mobile,
                starLevel

        );
    }

    public static SmsSignSuccess smsSignSuccess(String mobile, StarLevelEnum starLevel, LocalDateTime expireTime) {
        return new SmsSignSuccess(
                smsSignSuccessTemp,
                mobile,
                starLevel,
                expireTime
        );
    }


    public static SmsSignAuditSuccess smsSignAuditSuccess(String mobile) {
        return new SmsSignAuditSuccess(
                smsSignAuditSuccessTemp,
                mobile
        );
    }


    public static SmsSignAuditFail smsSignAuditFail(String mobile) {
        return new SmsSignAuditFail(
                smsSignAuditFailTemp,
                mobile
        );
    }

    public static SmsUnbindAccount smsUnbindAccount(String mobile) {

        return new SmsUnbindAccount(smsChargeUnbindAccountTemp, mobile);

    }

    public static SmsAccountChangeMode smsAccountChangeMode(String mobile, String newModeName, Integer autoCancelNum) {
        return new SmsAccountChangeMode(smsChargeModeChangeTemp, mobile, newModeName, autoCancelNum);
    }

    public static SmsAccountAuthFail smsAccountAuthFail(String mobile, String authModeName, String remark) {

        return new SmsAccountAuthFail(smsChargeAuthFailTemp, mobile, authModeName, remark);
    }


    public static SmsChargeDistributeFail smsChargeDistributeFail(String mobile) {
        return new SmsChargeDistributeFail(smsChargeDistributeFailTemp, mobile);
    }

    public static SmsChargeDistributeSuccess smsChargeDistributeSuccess(String mobile, String bankNo) {
        return new SmsChargeDistributeSuccess(smsChargeDistributeSuccessTemp, mobile, bankNo);
    }

    public static SmsChargeBatchPayment smsChargeBatchPayment(String mobile, String name, String code) {
        return new SmsChargeBatchPayment(smsChargeBatchPaymentCodeTemp, mobile, name, code);
    }

    public static SmsChargeApplyReject smsChargeApplyReject(String mobile) {
        return new SmsChargeApplyReject(smsChargeApplyVerifyFailTemp, mobile);
    }

    public static SmsChargeEarlyApplyPass smsChargeEarlyApplyPass(String mobile) {

        return new SmsChargeEarlyApplyPass(smsChargeEarlyVerifySuccessTemp, mobile);
    }

    public static SmsChargeEarlyApplyReject smsChargeEarlyApplyReject(String mobile) {
        return new SmsChargeEarlyApplyReject(smsChargeEarlyVerifyFailTemp, mobile);
    }

    public static SmsChargeRecheckReject smsChargeRecheckReject(String mobile) {
        return new SmsChargeRecheckReject(smsChargeRecheckRejectTemp, mobile);
    }

    public static SmsStarUpcomingNotice smsStarUpcomingNotice(String mobile) {
        return new SmsStarUpcomingNotice(smsStarUpcomingNoticeTemp,mobile);
    }

}
